﻿using Cinchoo.Core;
using Cinchoo.Core.Configuration;
using Cinchoo.Core.Xml.Serialization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ChoBulkFileProcessor
{
    [ChoNameValueConfigurationSection("matchFileOpsDefaultScriptSection", Silent = false)]
    public class ChoBulkFileOpsDefaultScriptsSettings : ChoConfigurableObject, IChoDefaultScriptSettings
    {
        [ChoPropertyInfo("csScript", DefaultValue =
@"if (args != null && args.Length >= 2)
{
    bool isPreview = (bool)args[0];
    string folderPath = (string)args[1];

    //TODO: Write custom code, return true/false
    if (isPreview)
    {
        //TODO: Do something when preview is ON
    }
    else
    {
        //TODO: Do something when preview is OFF

    }
}

//TODO: return true/false with optional status message seperated by ;
return true;
"
)]
        public ChoCDATA CSharpScript
        {
            get;
            set;
        }

        [ChoPropertyInfo("vbNetScript", DefaultValue =
@"If args IsNot Nothing AndAlso args.Length >= 2 Then
    Dim isPreview As Boolean = CBool(args(0))
    Dim folderPath As String = DirectCast(args(1), String)

    'TODO: Write custom code, return true/false
    If isPreview Then
        'TODO: Do something when preview is ON

    Else
        'TODO: Do something when preview is OFF
    End If
End If

'TODO: return true/false with optional status message seperated by ;
Return True
"
)]
        public ChoCDATA VBNetScript
        {
            get;
            set;
        }

        [ChoPropertyInfo("dosScript", DefaultValue =
@"@IF ""%~1""=="""" GOTO endparse
@IF ""%~2""=="""" GOTO endparse

@SET IS_PREVIEW=%~1
@SET FOLDER_PATH=%~2

@REM Write custom code, return true/false

@IF /I ""%IS_PREVIEW%""==""True"" (
@REM TODO: Do something when preview is ON

@GOTO endparse
)

@IF /I ""%IS_PREVIEW""==""False"" (
@REM TODO: Do something when preview is OFF

@GOTO endparse
)

:endparse

REM TODO: return true/false with optional status message seperated by ;
@ECHO True
"
)]
        public ChoCDATA DOSScript
        {
            get;
            set;
        }

        [ChoPropertyInfo("javaScript", DefaultValue =
@"if (WScript.Arguments.Count() >= 2)
{
    var isPreview = ""true"".toLowerCase() == WScript.Arguments(0).toLowerCase();
    var folderPath = WScript.Arguments(1);

    //TODO: Write custom code, return true/false
    if (isPreview)
    {
       //TODO: Do something when preview is ON
    }
    else
    {
       //TODO: Do something when preview is OFF
	}       
}

//TODO: return true/false with optional status message seperated by ;
WScript.Echo(""True"");
"
)]
        public ChoCDATA JavaScript
        {
            get;
            set;
        }

        [ChoPropertyInfo("vbScript", DefaultValue =
@"If WScript.Arguments.Count >= 2 Then
    isPreview = WScript.Arguments.Item(0)
    folderPath = WScript.Arguments.Item(1)

    'TODO: Write custom code, return true/false
    If (isPreview) Then
       'TODO: Do something when preview is ON
    Else
       'TODO: Do something when preview is OFF
    End If
End If

'TODO: return true/false with optional status message seperated by ;
WScript.Echo ""true""
"
)]
        public ChoCDATA VBScript
        {
            get;
            set;
        }
    }
}
